import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class HotUpdate {
    private Log log = LogFactory.getLog(HotUpdate.class);
    private HotUpdateTask hotUpdateTask;
    private String listenPath;

    public HotUpdate(String listenPath) {
        this.listenPath = listenPath;
    }

    public void start() {
        log.info("hot update task running.");
        if (hotUpdateTask == null) {
            hotUpdateTask = new HotUpdateTask(listenPath);
        }
        hotUpdateTask.setDaemon(true); // 设置为守护线程
        hotUpdateTask.start();
    }

    public void stop() {
        if (hotUpdateTask == null || !hotUpdateTask.isAlive()) {
            return;
        }
        hotUpdateTask.shutDown();
    }
}
